Starting from this release, WASTE will no longer be marked as “alpha”, even if I will keep considering the addition of new features and possibly even changes to the existing API. This is because WASTE seems pretty stable now so the “alpha” designation may be confusing.
WASTELib Shared Library
This distribution includes WASTELib, a version of WASTE packaged as a fat shared library which can be used on both PowerPC and 68020+ machines. Using WASTELib on 68K machines requires the CFM-68K Runtime Enabler. There are also two versions of the WASTE Demo app: a fat application (PPC/CFM68K) which links dynamically to WASTELib and a classic 68K application. WASTELib exports this new call:
extern pascal NumVersion WEVersion(void);
which returns the library version.
API Changes (!)
• The edge parameter in various calls is now declared of type WEEdge (= SInt8 = signed char), rather than char. This may require slight changes to source code.
• In preparation for a future right-to-left savvy version of WASTE, a new direction parameter was added to the WEGetPoint call. The new prototype looks like this:
extern pascal void WEGetPoint
(
SInt32 offset,
SInt16 direction,
LongPt *thePoint,
SInt16 *lineHeight,
WEReference we
);
Possible values for the direction parameter are leftCaret, rightCaret and hilite (defined in <QuickdrawText.h>). Until right-to-left support is properly implemented, you should always use hilite.
• The drag translation hook (WEDragTranslateProcPtr) has changed. Your callback should now be declared like this:
pascal OSErr MyTranslateDrag
(
DragReference drag,
ItemReference dragItem,
FlavorType requestedType,
Handle putDataHere,
SInt32 dropOffset,
WEReference we
)
While tracking a drag, WASTE will pass nil in putDataHere and -1 in dropOffset: your callback should return noErr if it can convert the specified drag item to the requested type, without actually supplying the data. If you can’t convert the drag item to the requested type, return badDragFlavorErr.
When the drag is eventually received, WASTE will call you again, passing a valid handle in putDataHere and a valid offset in dropOffset: this time your callback should supply the actual data.
Some applications may prefer to package the drag item data, the drop offset and the WASTE reference into some kind of “insert” Apple event to be handled asynchronously when the drag receive handler is returned; the new extra parameters are meant to make this process easier.
Other Changes
• WASTE now requires version 2.1 or newer of Apple’s Universal Headers.
• Moved Chris Thomas’s optional modifications to WEScroll to a separate routine, WEPinScroll, which parallels the TextEdit routine TEPinScroll. As a result, the macro WASTE_PIN_SCROLL is no longer supported.
• Following a suggestion by Timothy Paustian, I added a WEGetClickCount call.
• It is now safe to pass nil in the lineHeight parameter of WEGetPoint, if you don’t want that value returned.
• The macro WASTE_NO_RO_CARET now defaults to 1.
New in WASTE 1.2a7
Bug Fixes
• The null style bug fix in WASTE 1.2a6 had a nasty, subtle side effect that could corrupt internal data structures and cause sudden inexplicable crashes. (Hopefully) fixed. Bug fixes are evil. ;-)
• Fixed a number of bugs in the WASTE Demo code (thanks to Chris Thomas).
New in WASTE 1.2a6
New Features
• A new hook (weHiliteDropAreaHook) lets you customize the way WASTE highlights and unhighlights the text area during drag tracking. By default, WASTE uses the Drag Manager routines ShowDragHilite and HideDragHilite.
• A new mechanism lets you specify an initial refCon value for all embedded objects of a given type: if you call WEInstallObjectHandler like this:
WASTE will set the refCon of newly created objects of the given type to myInitialRefCon before calling the NewObject handler.
• A new call, WEGetObjectHandler, complements the existing WEInstallObjectHandler.
Bug Fixes
• Added some extra code to WESetStyle to work around a rather obscure problem in Tim Paustian’s PowerPlant WASTE wrapper and possibly in other WASTE-using software.
Setting the text style of an empty WASTE instance used to affect only the rather volatile internal “null style” record, but several WASTE calls, including WEReceiveDrag, invalidate the null style, effectively undoing the effects of the WESetStyle call. When called on an empty WASTE instance, WESetStyle will now propagate the changes to the style table, which can’t be modified except by an explicit call.
• WESetSelection will no longer draw the selection hilite if either weFInhibitRedraw or weFInhibitRecal is set.
Other Changes
• _WEOldWordBreak, _WEOldCharByte and _WEOldCharType are no longer compiled when building PowerPC projects, since they are only needed for system software prior to version 7.1.
New in WASTE 1.2a5
Bug Fixes
• Fixed a bug in _WEIntelligentPaste inadvertently introduced in version 1.2a4 (thanks to Andy Maloney).
• Fixed a bug in _WECopyStyle which affected the condensed and extended styles (thanks to Ed van Zon).
• WEGetChar would previously return negative values for character codes in the range 128 to 255. Fixed.
• The declarations for uppWEWordBreakProcInfo, uppWECharByteProcInfo and uppWECharTypeProcInfo (and thus the corresponding NewProc and CallProc macros) were incorrect, and the corresponding WEGetInfo/WESetInfo selectors were missing from the public WASTE header. Fixed (thanks to Todd Grinnell).
• Added some missing stuff to WEPascalPPCGlue.p.
Other Changes
• Corrected some minor bugs in the demo application.
• Recompiled the demo with CodeWarrior 8.
• Updated the Symantec project file to version 8.0.3 of SC++.
• Updated Internet Config files to version 1.2 of IC.
• Updated Marco’s email address and mailing list information.
• WASTE_KURTHS_OPTION_ARROWS is now TRUE by default.
New in WASTE 1.2a4
Bug Fixes
• “SOUP” handles are defined as a tightly concatenated sequence of descriptor + object data + descriptor + object data etc. Unfortunately, this means that if one of the object data blocks is an odd number of bytes, the following descriptor is misaligned. In fact, a couple of WASTE routines which directly access descriptors within soups crashed with an address error on 68000 machines (but not on 68020+ and PPC CPUs, which allow misaligned accesses to memory, albeit with a performance penalty).
If caught early, this design flaw could have been fixed by adding some extra padding bytes in situations like this, but changing the SOUP format now would break existing applications, so I chose to fix this bug by modifying the relevant routines to use BlockMoveData to access descriptors within soup handles.
• Added a line to _WEHandleUpdateActiveInputArea which is supposed to fix an incompatibility with a commercial input method for KanjiTalk and possibly other input methods as well. Thanks to Kiyoshi Gomasaki for reporting the problem and suggesting the fix.
• WEScroll would sometimes incorrectly redraw the text if you passed values larger than 32,767 in vOffset, since the Toolbox call ScrollRect takes short (16-bit) offsets, while WEScroll deals with long (32-bit) quantities. Now WEScroll uses a different algorithm when passed large offsets, which fixes this bug and allows for smoother scrolling. Thanks to Lee Fyock for reporting the bug and for suggesting the fix.
• WEUpdate was slightly retouched to prevent a rare cosmetic problem.
• In previous versions of WASTE, calling WEUseText on a non-empty instance was not supported and could cause crashes. Now it should be safe to call WEUseText at any time.
• The built-in click loop routine will no longer auto-scroll the text in inactive WE instances.
• The function prototype for WEGetLineRange in WASTE.h was wrong. Thanks to Romain Vignes and Dan Crevier for pointing this out.
Other Changes
• Handling of URL resolution has been improved. Now WASTE will let you pass an existing selection to Internet Config without forcing a re-parse.
Additionally, now you can associate “URL hints” to WASTE instances using WESetInfo with the weURLHint selector. URL hints are strings used by Internet Config to parse “slack” (scheme-less) URLs like “xxx@yyy”: refer to the Internet Config programmer’s documentation for more details.
Here’s some sample code that sets the URL hint of a WASTE instance to “mailto”:
OSErr MyWESetDefaultURLHint(WEReference we)
{
static StringHandle hint = NewString("\pmailto");
return WESetInfo(weURLHint, &hint, we);
}
Thanks to Stefan Kurth for suggesting these changes.
• I incorporated some code by Jud Spencer which prevents style information from being applied when pasting or dragging text into a WASTE instance if a certain feature flag (weFMonoStyled) is enabled. This flag also forces WECopy to copy only the TEXT info to the desk scrap.
• I incorporated some code by Stefan Kurth which implements the option + left/right arrow key combinations according to Apple’s Human Interface Guidelines. The old code is still present, however, and you can choose your favorite implementation by setting a compiler variable (WASTE_KURTHS_OPTION_ARROWS) in your prefix file.
• The mode parameter in WESetStyle and WEContinuousStyle is now declared as WEStyleMode (= unsigned short), rather than short.
New in WASTE 1.2a3
Bug Fixes
• Fixed a bug reported by Tom Bender that had been lurking in WASTE since the very first release. To see what the bug was, try this in an older version of the WASTE Demo: type “foo bar”, double-click “foo” to select it, and type “moof” to replace “foo”. Now the caret is at the end of the word “moof”. Shift-click at the end of “bar”. See what happened? “moof” was incorrectly included in the selection.
• With earlier versions of WASTE it was sometimes possible to start a drag with the cursor incorrectly set to an I-beam. To see how, try this in an older version of the WASTE Demo: type “sometimes”, double-click “some”, quickly move the cursor over “times” and click again before the cursor turns into an arrow. Now WASTE always turns the cursor into an arrow before starting a drag.
API Changes
• The flags parameter in WENew is now an unsigned long quantity, to allow for up to 32 features to be set independently.
• Following a suggestion by Dan Crevier, a new feature flag has been added: weFInhibitRedraw. I think Dan said this feature will be used in a new version of the WASTE TCL classes.
• WASTE now has a built-in click loop routine that provides default autoscrolling behavior. Replacing the built-in click loop is still possible, of course, but wait: most applications using TextEdit or earlier versions of WASTE install a click loop callback for the sole purpose of keeping the scroll bars in sync with the text, and WASTE provides a simpler mechanism for this (i.e., the scroll callback), so from now on click loops should prove unnecessary in many cases.
• I added a WEGetLineRange call that returns the start and end offsets of a line given its line number (first line = 0).
• I added a WEUseSoup call to complement the existing WEUseStyleScrap. Given a soup handle, this new call applies it to the selection range, much like WEUseStyleScrap does for a 'styl' handle.
New WASTE Demo application
WASTE 1.2a3 comes with a new WASTE Demo application, written in C, brought to you by John C. Daub and me (Marco). This demo is mainly based on the pascal demo app, but with a few differences:
• John added some functionality lacking in the original code, e.g. better handling of the save command. I plan to add more features in the future (e.g., printing).
• The demo is based on version 2.1 of the Universal Headers and it can be compiled with the STRICT_WINDOWS, STRICT_CONTROLS and STRICT_MENUS options turned on. This required a few changes in the code.
Other Changes
• Pascal support is back. I have included updated interface and glue files needed to use WASTE from a Pascal program.
• This version supports the Symantec C++ 8.0 compiler. A project file for the demo app is included in the distribution.
• The WASTE.h public header file now defines the WASTE_VERSION macro as the current version of the library, in standard NumVersion format (e.g., version 1.2a3 is expressed as 0x01204003).
• WASTE now allows lines to be one pixel tall. Previously WASTE forced the line height to be at least two pixels, even when using very small font sizes. Thanks to Jeff Gold for suggesting this change.
New in WASTE 1.2a2
• Switched to version 2.1 of the Universal Headers (MacOSEventModifiers is now called EventModifiers). Version 2.0 is still supported, though.
• You can now #define variables like WASTE_DEBUG and WASTE_IC_SUPPORT in a prefix file compiled before WASTEIntf.h, if you want to override the default settings. Previously, you had to make changes to WASTEIntf.h. (Thanks to Dan for suggesting this.)
• Due to overwhelming popular demand, WECalText no longer redraws the text after recalculating line breaks, unless WASTE_WECALTEXT_DOES_REDRAW is #defined to TRUE when WASTE is compiled.
• Time-related quantities expressed in ticks are now declared as unsigned long rather than long, as per the Universal Headers. Some API functions were changed accordingly.
• Worked around an obscure bug in the System whereby the Drag Manager calls _WESendFlavor with a bogus A5 world when a WASTE-generated drag ends up in a TSM floating window. You can reproduce this bug using “HoverBar”, a shareware program. This bug only affects 68K binaries.
• WESetStyle now accepts a new mode, weDoFaceMask, which lets you set some styles, clear other styles and leave all other styles untouched, all in a single call. When you use this mode, the filler byte of the TextStyle record passed to WESetStyle is used as a mask which determines which styles are affected. Here’s an example:
TextStyle ts;
OSErr err;
// set the bold style and clear the italic style,
// without touching any other style
ts.tsFace = bold;
ts.filler = bold + italic;
err = WESetStyle(weDoFaceMask, &ts, we);
This feature should prove useful for scripting purposes.
New in WASTE 1.2a1
• This version is based on Dan’s C-WASTE 1.1r16. I will no longer support the Pascal version.
• I made several changes to the source code in an attempt to remove some “pascalisms” that look a bit ugly in C. ;-)
• Some frequently used routines in WELowLevelEditing have been slightly optimized.
• Many WASTE-based applications don’t need embedded objects, so WASTE can now be compiled without the code for supporting them: just #define WASTE_OBJECTS to 0 in WASTEIntf.h.
The API will remain the same, with the following exceptions:
- The tsObject field of the WERunInfo record returned by WEGetRunInfo will be undefined, so your app should ignore it.
- WASTE will ignore the hSoup parameter in WECopyRange and WEInsert, so pass NULL in hSoup.
- Routines like WEInsertObject, WEInstallObjectHandler, etc. won’t be compiled, so attempts to use them will result in link errors.
• It is now safe to pass NULL in the edge parameter of WEGetOffset if you don’t want the value returned.
• Ditto for the redoFlag parameter of WEGetUndoInfo.
• On PPC systems, WENew now uses a different strategy for determining if a double-byte script system is installed, since the WorldScript Power Adapted breaks the usual check for smDoubleByte. I haven’t checked if this works, though.
• On PPC systems, WENew makes sure that the address of NewDrag is non-zero before assuming that the Drag Manager is available.
• WESetStyle now accepts two extra flags in the mode parameter, that allow you to change the font in a script-sensitive manner. This feature has not been thoroughly tested yet. Thanks to Jonathan Kew for providing the code.
• You can now supply an optional “streaming” object handler that WASTE will use to get “flat” data from an object to be written to the Clipboard, to a drag or to a soup. This is an untested experimental feature that may change in future versions.
• Operations involving heavily styled text should now be significantly faster. Previously WASTE would call the Font Manager routine GetFontInfo once for each style run when applying a style scrap. The Metrowerks Profiler revealed that this call is very time consuming, so now GetFontInfo is only called for new styles that aren’t used anywhere else in the text.